﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ManageBooks.ascx.cs" Inherits="ManageBooks" %>

<%@ Register assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

<h3>Manage Books</h3>

<%-- stores library ID, loaded from page load,  --%>
<asp:Label ID="lblLibID" runat="server" Text=" " Visible="false"></asp:Label>
    
<div  class="featurebox_center">

    <%--search for a book--%>
    <h4><asp:Label ID="lblSearch" runat="server" Text="Search by ISBN, Barcode, Title, Author, or Call Number: "></asp:Label></h4>
    <br />
    <asp:TextBox ID="txtFindBook" runat="server"></asp:TextBox>
    <asp:Button ID="btnFindBook" runat="server" Text="Find Book" onclick="btnFindBook_Click" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="btnAddNew" runat="server" Text="Add New Book" onclick="btnAddNew_Click" />
    &nbsp;&nbsp;
    <%--<asp:Button ID="btnManagePublisher" runat="server" Text="Manage Publisher" onclick="btnNewPublisher_Click" />--%>
    <br /><br />
    <div class="confirmLabel">
        <asp:Label ID="lblNoResults" runat="server" Text=""></asp:Label>
    </div>
    <br />
    
    <%--grid displays results of searching for a book--%>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Barcode" 
         AllowPaging="True" AllowSorting="True"  
         OnRowCommand="GridView1_SelectedIndexChanged"  >
        <Columns>
            <asp:BoundField DataField="Barcode" HeaderText="Barcode" SortExpression="Barcode" />
            <asp:BoundField DataField="ISBN" HeaderText="ISBN" SortExpression="ISBN" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
            <asp:BoundField DataField="CallNumber" HeaderText="Call Number" SortExpression="Call Number" />
            <asp:CommandField ShowSelectButton="True" SelectText="Select" ButtonType="Link" 
                 EditText="Select" />
        </Columns>
        <HeaderStyle Font-Bold="True" ForeColor="#2153AA" />
    </asp:GridView>

    <br />
    <br />

    <%--displays detail view of selected item in data grid--%>
    <asp:DetailsView ID="DetailsView1" runat="server" DataKeyNames="Barcode" 
         AutoGenerateRows="False" OnItemUpdating="DetailsView1_ItemUpdating" GridLines="None"
         OnItemInserting="DetailsView_ItemInserting"  OnItemCommand="DetailsView1_onItemCommand"
        OnModeChanging="DetailsView1_ModeChanging"   >
        <RowStyle Font-Bold="False" ForeColor="Black" />
        <FieldHeaderStyle Font-Bold="True" ForeColor="#2153AA" />
        <Fields>        
            <asp:TemplateField HeaderText="Barcode">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Barcode") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvBarcode" ControlToValidate="TextBox1" runat="server"
                    ErrorMessage="You must enter a Barcode" ValidationGroup="mbRequired"> </asp:RequiredFieldValidator>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Barcode") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvBarcode" ControlToValidate="TextBox1" runat="server"
                    ErrorMessage="You must enter a Barcode" ValidationGroup="mbRequired"> </asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Barcode") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ISBN">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ISBN") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ISBN") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("ISBN") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Title">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvTitle" ControlToValidate="TextBox1" runat="server"
                    ErrorMessage="You must enter a Title" ValidationGroup="mbRequired"> </asp:RequiredFieldValidator>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvTitle" ControlToValidate="TextBox1" runat="server"
                    ErrorMessage="You must enter a Title" ValidationGroup="mbRequired"> </asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Author">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Author") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvAuthor" ControlToValidate="TextBox1" runat="server"
                    ErrorMessage="You must enter a Author" ValidationGroup="mbRequired"> </asp:RequiredFieldValidator>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Author") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvAuthor" ControlToValidate="TextBox1" runat="server"
                    ErrorMessage="You must enter a Author" ValidationGroup="mbRequired"> </asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Author") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Series Title">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("SeriesTitle") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("SeriesTitle") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("SeriesTitle") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Call Number">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CallNumber") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CallNumber") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("CallNumber") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Date Published">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("DatePublished") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("DatePublished") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("DatePublished") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Subject">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Subject") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Subject") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label8" runat="server" Text='<%# Bind("Subject") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Keywords">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("Keywords") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("Keywords") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label9" runat="server" Text='<%# Bind("Keywords") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Is Young Adult?">
                <EditItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                        Checked='<%# Bind("isYoungAdult") %>' />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                        Checked='<%# Bind("isYoungAdult") %>' />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                        Checked='<%# Bind("isYoungAdult") %>' Enabled="false" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
        </Fields>
     </asp:DetailsView>
     
     <%--sql datasource for details view--%>
    <asp:SqlDataSource 
        ID="SqlDataSource_DetailsView" runat="server"
        ConnectionString="<%$ ConnectionStrings:BPI_LibraryConnectionString %>" 
        UpdateCommand="usp_BOOK_LibrarianBookUpdate" UpdateCommandType="StoredProcedure"
        InsertCommand="usp_BOOK_LibrarianBookInsert" InsertCommandType="StoredProcedure">
    </asp:SqlDataSource>
     
     <div class="confirmLabel">
     <br />
         <asp:Label ID="lblConfirm" runat="server" Text="" Class="confirmLabel"></asp:Label>
     </div>
   
</div>
<asp:Button ID="btnRpt" runat="server" Text="Reserved Books To Pull Report" />
<asp:Panel ID="pnlReport" runat="server" Visible="false" >
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
        AutoDataBind="True" BestFitPage="True" 
        ReportSourceID="CrystalReportSource1" />

    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
        <Report FileName="Reports\cr_librarianRsvdBksToPull.rpt">
        </Report>
    </CR:CrystalReportSource>
</asp:Panel>

